<%@ page import="org.codehaus.groovy.grails.plugins.springsecurity.SpringSecurityUtils; com.the8thfold.anton.users.Roles" %>
<table>
    <tr>
        <th></th>
        <th>Name</th>
        <th>Value</th>
        <th>Default Value</th>
    </tr>
    <g:each in="${job.propertyValues.sort{it.name}}" status="propertiesIndex" var="propertyItem">
        <tr class="${propertiesIndex%2 ? 'odd' : 'even'}">
            <td style="width: 64px;">
                <div class="toolbar">
                    <g:if test="${SpringSecurityUtils.ifAllGranted(Roles.ROLE_JOB_ADMIN.toString())}">
                        <nobr>
                        <a class="btn" icon="ui-icon-trash" title="Remove this property override from this job." onclick="return confirm('Are you sure?');" href="${createLink(controller: 'job', action: 'deleteProperty', id: propertyItem.propertyId)}"></a>
                        <g:remoteLink  onSuccess="jQuery('#${propertyItem.propertyId}').val(data);jQuery('#${propertyItem.propertyId}').effect('highlight',{color: '#90ee90'},2000);" class="btn" icon="ui-icon-arrowrefresh-1-n" title="Restore default value." controller='job' action='restoreDefault' id="${propertyItem.propertyId}"></g:remoteLink>
                        </nobr>
                    </g:if>
                </div>
            </td>
            <td>${propertyItem.name}</td>
            <td style="width: 60%;">
                <g:if test="${SpringSecurityUtils.ifAllGranted(Roles.ROLE_JOB_ADMIN.toString())}">
                    <g:formRemote after="jQuery('#${propertyItem.propertyId}').effect('highlight',{color: '#90ee90'},1000);" name="f${propertyItem.propertyId}" url="[controller: 'job', action: 'updateProperty', id: job.jobId]">
                        <g:hiddenField name="propertyId" value="${propertyItem.propertyId}"/>
                        <input id="${propertyItem.propertyId}" class="ui-corner-all" type="text" name="value" value="${propertyItem.value}"/>
                        <a title="Save value" href="javascript: void();" onclick="jQuery('#f${propertyItem.propertyId}').submit();" name="submit" value="" href="#" class="btn save" icon="ui-icon-disk"></a>
                    </g:formRemote>
                </g:if>
                <g:else>${propertyItem.value}</g:else>
            </td>
            <td>${propertyItem.defaultValue}</td>
        </tr>
    </g:each>
</table>